package com.zeroup.auto;

import android.content.Context;

import com.zeroup.auto.bean.User;

import org.kymjs.kjframe.KJDB;

public class UserService {


    public static void saveOrUpdate(Context context, User user){
        KJDB kjdb = KJDB.create(context);
        User dbUser = kjdb.findById(1,User.class);
        if(dbUser==null){
            user.setId(1);
            kjdb.save(user);
        }else{
            dbUser.setUserName(user.getUserName());
            dbUser.setSbh(user.getSbh());
            kjdb.update(dbUser);
        }
    }


    public static User findUser(Context context){
        KJDB kjdb = KJDB.create(context);
        return kjdb.findById(1,User.class);
    }
}
